package com.mall.controller;

import com.mall.domain.OrderDetails;
import com.mall.service.IOrderDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class OrderDetailsController {

	@Autowired
	private IOrderDetailsService iOrderDetailsService;

	@RequestMapping("/findOrderDetailsById")
	public @ResponseBody
	Map<String,Object> findOrderDetailsById(HttpServletRequest request){
		String id = request.getParameter("orders_id");
		Map<String,Object> orderDetailsMap = new HashMap<>();
		//获取商品类别集合
		List<OrderDetails> orderDetails = iOrderDetailsService.findOrderDetailsById(id);
		//放入Map集合
		orderDetailsMap.put("message",orderDetails);

		//创建状态Map
		Map<String,Object> metaMap = new HashMap<>();
		metaMap.put("msg","获取订单详情成功");
		metaMap.put("status",200);

		orderDetailsMap.put("meta",metaMap);
		return orderDetailsMap;
	}
}
